// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   CountryDAO.java

package com.nervytech.tutorcruise.db.dao.mysql.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.nervytech.tutorcruise.db.dao.interfaces.ICountryDAO;

@Repository("countryDAO")
public class CountryDAO extends JdbcDaoSupport implements ICountryDAO {

	@Autowired
	CountryDAO(DataSource dataSource) {
		setDataSource(dataSource);
	}

	public String getCountryName(int countryId) {
		return null;
	}

	public int getCountryId(String countryName) {
		return 0;
	}

	public Map<Integer, String> getCountryMap() {
		final Map<Integer, String> catsMap = new LinkedHashMap<Integer, String>();
		String selectCatsQuery = "SELECT * FROM country";
		logger.debug((new StringBuilder("Select user Query : ")).append(
				selectCatsQuery).toString());
		getJdbcTemplate().query(selectCatsQuery,
				new ResultSetExtractor<Object>() {

					public Object extractData(ResultSet rs)
							throws SQLException, DataAccessException {
						for (; rs.next(); catsMap.put(
								Integer.valueOf(rs.getInt("country_id")),
								rs.getString("name")))
							;
						return null;
					}

				});
		return catsMap;
	}
}
